package com.atghost.miniofile.dto.res;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Admin
 * @version 1.0
 * @date 2024-5-19 11:32
 **/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CommResp {
    /**
     * 接口返回状态，成功true
     **/
    private Boolean operateSuccess;

    /**
     * 接口返回消息
     **/
    private String msg;

    /**
     * 第几页
     **/
    private Integer pageNo;

    /**
     * 每页数量
     **/
    private Integer pageSize;

    /**
     * 数量总数
     **/
    private Long totals;

    /**
     * @description 设置成功Bo
     */
    public static void setResp(CommResp resp, CommBo bo) {
        if (bo != null) {
            resp.setMsg(bo.getMsg());
            resp.setOperateSuccess(bo.getOperateSuccess());
            if (bo.getPageNo() != null) {
                resp.setPageNo(bo.getPageNo());
            }
            if (bo.getPageSize() != null) {
                resp.setPageSize(bo.getPageSize());
            }
            if (bo.getTotals() != null) {
                resp.setTotals(bo.getTotals());
            }
        } else {
            resp.setMsg("不存在");
            resp.setOperateSuccess(false);
        }
    }

}
